﻿<%@ Page Title="Manage users" Language="C#" MasterPageFile="~/Backoffice/BackOffice.Master"
    AutoEventWireup="true" CodeBehind="ManageUsers.aspx.cs" Inherits="TreaShares.Backoffice.Administrator.ManageUsers" %>

<%@ MasterType VirtualPath="~/Backoffice/BackOffice.Master" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AutoGenerateColumns="false"
        DataKeyNames="UserName, RoleName" OnRowCommand="GridView1_RowCommand" 
        onrowcreated="GridView1_RowCreated">
        <Columns>
            <asp:BoundField DataField="UserName" HeaderText="User Name" ReadOnly="True" SortExpression="UserName" />
            <asp:CommandField ButtonType="Image" SelectImageUrl="~/Images/Icons/male.gif" HeaderText="Login As"
                HeaderStyle-HorizontalAlign="Center" ShowSelectButton="True"  ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="Name" HeaderText="Organisation" SortExpression="Name" />
            <asp:BoundField DataField="RoleName" HeaderText="Role Name" SortExpression="RoleName" />
            <asp:BoundField DataField="LastActivityDate" HeaderText="Last Activity Date" SortExpression="LastActivityDate"
                DataFormatString="{0:f}" />
            <asp:BoundField DataField="Email" HeaderText="Email"  />
            
            <asp:TemplateField HeaderText="Delete" HeaderStyle-HorizontalAlign="Center">
                <ItemStyle HorizontalAlign="Center" />
                <ItemTemplate>
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/Icons/trash.gif"
                        CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete')" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            No Records found
        </EmptyDataTemplate>
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetOrganisationUsers"
        TypeName="TreaShares.Backoffice.Controlers.UsersManager" DeleteMethod="DeleteUser">
        <DeleteParameters>
            <asp:Parameter Name="UserName" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:CookieParameter Name="organisationId" CookieName="organisationId" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <%--<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetOrganisationUsers"
        TypeName="StrongerOrg.Backoffice.Entities.UsersManager" DeleteMethod="DeleteUser">
        <DeleteParameters>
            <asp:Parameter Name="UserName" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtSearchParam" Name="searchKey" PropertyName="Text"
                Type="String" />
            <asp:ControlParameter ControlID="ddlSearchBy" Name="searchByKey" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>--%>
    <br />
    <table border="0" style="width: 50%" cellpadding="2" cellspacing="2">
        <tr>
            <td colspan="2" class="HeaderStyle">
                Sign Up for New Account to
                <%= Master.OrgBasicInfo.Name%>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="txtUserName">User Name:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="txtUserName"
                    ErrorMessage="User Name is required." ToolTip="User Name is required.">User Name is required</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="txtPassword">Password:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtPassword"
                    ErrorMessage="password must be betwenn 6-12 chars" ValidationExpression="[\S\s]{6,12}"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="txtEmail">E-mail:</asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="txtEmail"
                    ErrorMessage="E-mail is required." ToolTip="E-mail is required." Display="Dynamic">*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                    Display="Dynamic" ErrorMessage="Email is not valid" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server">Role:</asp:Label>
            </td>
            <td>
                <asp:RadioButtonList ID="rbRoles" runat="server">
                    <asp:ListItem Selected="True">PowerUser</asp:ListItem>
                    <asp:ListItem Selected="True">User</asp:ListItem>
                    <%-- <asp:ListItem>Accountants</asp:ListItem>
                    <asp:ListItem Value="ContentManager">Content manager</asp:ListItem>
                    <asp:ListItem Value="LockSmithUser">LockSmithUser</asp:ListItem>
                    <asp:ListItem Value="MiriMargolinDelegate">MiriMargolin</asp:ListItem>--%>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2">
                <asp:Button Text="Create user" runat="server" OnClick="Unnamed1_Click" ID="lbUser" CssClass="button" />
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2" style="color: Red;">
                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
            </td>
        </tr>
    </table>
</asp:Content>
